Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate and present custom error for not in allowed emails coupons #43872

Merged

Conversation

wavvves
Copy link
Contributor

@wavvves wavvves commented Jan 22, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR introduces upfront validation in allowed emails coupons, opposed to the current procedure of adding the coupons and removing them when placing the Order if the billing email does not match the coupon whitelist of emails.
It also updates the error messages presented to the user, stating clearly why the coupon was not accepted and how to proceed to use it effectively.

Cart Checkout
Blocks image image
Shortcode image image

Closes #26289
Closes #26305

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Prior to testing

  1. Create four pages with Shortcode Cart, Shortcode Checkout, Blocks Cart and Blocks Checkout
  2. In WC Settings, set the Cart page to the Shortcode Cart page you created (we need this to avoid the bug reported here Classic Cart fails to render after applying coupons when it is not set as the default Cart page #44232 )
  3. Go to Marketing > Coupons
  4. Create a new coupon restricted to the email allow@yay.com (make sure this email is not associated with your account), with any discount amount
  5. Create another coupon named "test" without restrictions, with any discount amount
  6. Add some items to your cart.

Shortcode Cart Test

  1. Go to the shortcode cart page
  2. Apply the coupon "test" and verify it gets applied and the totals update
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error notice is displayed

Blocks Cart test

  1. Go to the Blocks Cart page
  2. Apply the coupon "test" and verify it gets applied and the totals update
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error is displayed

Shortcode Checkout test

  1. Go to the shortcode Checkout page
  2. Fill the email field to something else than "allow@yay.com"
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error notice is displayed
  4. Change the email field to "allow@yay.com"
  5. Apply the restricted coupon and verify it gets applied correctly
  6. Place the order and verify applied discounts were effective

Blocks Checkout test

  1. Go to the Blocks Checkout page
  2. Fill the email field to something else than "allow@yay.com"
  3. Apply the restricted coupon and verify it doesn't get applied, and the proper error is displayed
  4. Change the email field to "allow@yay.com"
  5. Apply the restricted coupon and verify it gets applied correctly
  6. Place the order and verify applied discounts were effective

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@wavvves wavvves linked an issue Jan 22, 2024 that may be closed by this pull request
3 tasks
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 22, 2024
Copy link
Contributor

github-actions bot commented Jan 22, 2024

Test Results Summary

Commit SHA: 018c790

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 39s
E2E Tests780028003587m 6s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@wavvves wavvves self-assigned this Jan 31, 2024
@wavvves wavvves changed the title Deny and present custom error message for not in allowed emails coupons Present custom error message for not in allowed emails coupons Jan 31, 2024
@wavvves wavvves changed the title Present custom error message for not in allowed emails coupons Present custom notice for not in allowed emails coupons Jan 31, 2024
@wavvves wavvves changed the title Present custom notice for not in allowed emails coupons Validate and present custom error for not in allowed emails coupons Feb 2, 2024
@woocommercebot woocommercebot requested a review from a team March 12, 2024 17:50
Copy link
Member

@nielslange nielslange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @wavvves. While reviewing it, I noticed the cart-related error message on the checkout shortcode page. I left a comment for that. Apart from that, the PR is working as expected. I just mentioned a few nitpicks to potentially improve the readability, and I left a comment regarding extending the test cases to cover all affected pages (cart and checkout blocks and shortcodes).

@nielslange nielslange self-requested a review March 19, 2024 13:29
Copy link
Member

@nielslange nielslange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've successfully tested this PR, @wavvves. Thanks for this improvement. 🙌

@wavvves wavvves merged commit 0a3cf74 into trunk Mar 20, 2024
63 of 64 checks passed
@wavvves wavvves deleted the enhancement/26289-coupons-allowed-emails-dont-work-as-expected branch March 20, 2024 10:19
@github-actions github-actions bot added this to the 8.8.0 milestone Mar 20, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Mar 20, 2024
@Stojdza Stojdza added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Mar 20, 2024
@MartePower
Copy link

Hi, first chance to write here after years of reading.
I am writing because I find this change a deterioration and it hurt us in the last marketing campaign. It reduced the conversion rate of the email sent to newsletter subscribers.
Granted that the average customer has trouble doing even the simplest things and this change.

In sending the newsletter we use dynamic links that allow automatic activation of the discount code. In the past many requests for assistance on how to enter the code and even if there was a step-by-step guide in the email itself.

We use webtoffee's scondo coupon creation and segionre solution.
This mode allowed us with simple to send unique and personal codes tied to the e-mail. With the discount code valued according to the e-mail. https://www.xxxxxxx.xx/?add-to-cart=0000&quantity=1&e-redirect=https://www.xxxxxxx.xx/en/cart/?wt_coupon=000000000
The link proposed by the plug-in itself would not work either https://www.xxxxxxx.xx/en/cart/?wt_coupon=000000000

The usefulness of this restriction is totally missed since the link is sent to the same e-mail as the code.
The user is not necessarily registered for e-commerce or the session may have expired.
The code entered is deleted. The customer must enter the data manually in checkout and then go to enter the discount code. A drastic deterioration of User eXprience that reduces conversions taking into account that customers tend to be lazy and inattentive.

In the previous situation the order was communue blocked if the email was incorrect without creating problems to the buying experience or worse blocking it and then not taking it back. Lost sales even if few at the end of the year make up the number.

If anyone can explain to me the real need for the change I would be happy to understand why it was really needed. I can't find the reason since the code couldn't be used anyway.
Now instead we had to proceed with a second mailing with a discount code not tied to the email and it is worse.

Thank you
Alessio

@gianloga
Copy link

Hello,
in this case the Woocommerce team did not reason according to the best practices of UX and CRO.
The immediate validation of the discount code in the shopping cart (and in the checkout) should only be implemented to check if that code really exists. The alert for email verification creates friction in users that results in lost conversions.
This is not an improvement.
Have a nice day
Gianloga

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: coupon Issues related to coupons. focus: e2e tests Issues related to e2e tests needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Rubik Store API checkout endpoints, Mini-Cart, Cart and Checkout related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coupon current user validation Coupons -> Allowed Emails don't work as expected